package emulator.hardware.io;

public class Counter {

	int load_delay = 0;
	int value = 0;
	
	public void load(int value)
	{
		this.value = value;
		load_delay = 2;
	}
	
	int countDown()
	{
		if (load_delay > 0)
		{
			load_delay--;
			return value;
		}
		if (value > 0)
		{
			value--;
			return value;
		}
		return -1;
	}

	public int getValue() {
		return value;
	}
}
